import {CouponModel} from '../../../../models/CouponModel.js'
const base64  = require('../../../../utils/base64.js');
var aes  = require('../../../../utils/aes.js');

var CusBase64 = require('../../../../utils/base64.js');
let Coupon = new CouponModel()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        radio: '1',
        beginDay: '2016-09-01',
        endDay:'2016-09-01',
        time: '12:01',
        couponName:'',
        subPrice:'',
        sumPrice:'',
        coupons:[],
        
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this._init()
        /* 使用*/
        
var result=CusBase64.CusBASE64.encoder('count');
var result2=CusBase64.CusBASE64.decoder(result);
console.log('result',result)
console.log('',result2)
  },
    onShow:function(){
        this._init()
    },
    _init:function(){
        this._getCoupons()
        /* 引入 */


/* 使用 */
 
    },
    _getCoupons:function(){
        Coupon.getCoupon({},res=>{
            let coupons = res.result.data.data
            if(coupons.length > 0){
                this.setData({coupons})
            }
            console.log('res',coupons)
        })
    },  
   
   showDetail:function(e){
       let couponId = e.detail.couponId
        console.log('e',couponId)
        wx.navigateTo({
          url: '../modifyCoupon/modifyCoupon?couponId=' + couponId,
        })
   },
   addCoupon:function(){
        wx.navigateTo({
          url: '../addCoupon/addCoupon',
        })
   },


   
})